package com.hesicare.adapter.service.impl;

import com.hesicare.adapter.entity.ElectronicSignature;
import com.hesicare.adapter.service.IParseSginImageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.hesicare.untils.sginutils.sginUtil.byte2image;

/**
 * @Author 55097
 * @create 2022/1/6 20:20
 */
@Service
public class ParseSginImageServiceImpl implements IParseSginImageService {

    @Value("${sginUrl}")
    private String path;

    protected final static Logger log = LoggerFactory.getLogger(ParseSginImageServiceImpl.class);

    @Override
    public void parseSginImage(Object obList) {
        List<ElectronicSignature> electronicSignatureList = (List<ElectronicSignature>) obList;
        if (!electronicSignatureList.isEmpty() && electronicSignatureList != null) {
            log.info("电子签名总数{}", electronicSignatureList.size());
            electronicSignatureList.stream().forEach(electronicSignature -> {
                byte2image(electronicSignature.getQMNR(), path, electronicSignature.getZGID());
            });
        }
    }
}
